package boun.swe.bob.service;

import com.google.common.collect.Maps;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * This controller is used for inbox page actions
 */
public class MyInboxController extends BaseController {

        /**
     * Shows the page
     *
     * @param httpServletRequest http request
     * @param httpServletResponse http response
     * @return page
     */
     @RequestMapping(method = RequestMethod.GET)
    public ModelAndView showPage(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        Map<String, Object> myModel = Maps.newHashMap();
         myModel.put("userMessages",userMessageDao.findInboxRootMessagesByUserId(getLoggedInUser(httpServletRequest).getUserId()));
         myModel.put("user", userDao.findByPrimaryKey(getLoggedInUser(httpServletRequest).getUserId()));
         //myModel.put("message_count",userDao.findByPrimaryKey(getLoggedInUser(httpServletRequest).getUserId()).getInboxList().size());
         myModel.put("himself",  true  );
        return new ModelAndView("inbox", "model", myModel);
    }
}
